package com.example.demoserver.util;


import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptConfig implements WebMvcConfigurer {
    private final AppPropertyConfig appPropertyConfig;

    public InterceptConfig(AppPropertyConfig appPropertyConfig) {
        this.appPropertyConfig = appPropertyConfig;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加拦截器
        registry.addInterceptor(new JwtInterceptor(appPropertyConfig))
                //放行的路径
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/user/outlogin")
                .excludePathPatterns("/train/traindetail")
                .excludePathPatterns("/train/templateurl")
                .excludePathPatterns("/train/select")
                .excludePathPatterns("/train/selectbycode")
                .excludePathPatterns("/")
                .excludePathPatterns("/index.html")
                .excludePathPatterns("/static/**");
    }
}
